package com.goodving.guli.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.activity.SearchSingleBraceletActivity;
import com.goodving.guli.activity.ff;
import com.goodving.guli.activity.fh;
import com.goodving.guli.bt.lua.SlidingUpPanelLayout;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.bt.ui.C1795p;

import cn.com.smartdevices.bracelet.config.Config;

/**
 * Created by john on 2015/12/4.
 */
public class BindDevicesBandFragment extends C1795p implements View.OnClickListener { // C1796A
    private static final String TAG = "BindDevicesBandFragment";
    private static final int f8753c = 257;
    private TextView f8754d;
    private SlidingUpPanelLayout f8755e;

    private void m13560d() {
        fh a = new ff(getActivity()).m14851a();
        if (a.m14878d()) {
            int e = a.m14879e();
            int dimensionPixelSize = getResources().getDimensionPixelSize(R.dimen.main_ui_panel_height);
            GuliLog.tracePrintInfo(TAG, "SlidingPanel SystemBarH : " + e + ", OriginalPanelH : " + dimensionPixelSize);
            this.f8755e.setPanelHeight(dimensionPixelSize - e);
        }
    }

    public void m13561c() {
        GuliLog.tracePrintInfo(TAG, "On start bind clicked!!");
        startActivityForResult(new Intent(getActivity(), SearchSingleBraceletActivity.class), f8753c);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        GuliLog.tracePrintInfo(TAG, "onActivityResult requestCode = " + i + ", resultCode " + i2);
        if (i == f8753c && i2 == -1 && getActivity() != null) {
            getActivity().finish();
        }
        super.onActivityResult(i, i2, intent);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.about_mi_band:
//                C0891d.m9079a(getActivity(), true);
            case R.id.start_bind:
                m13561c();
            default:
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View inflate = layoutInflater.inflate(R.layout.activity_bind_devices_band, viewGroup, false);
        this.f8754d = (TextView) inflate.findViewById(R.id.about_mi_band);
        this.f8754d.setText(Html.fromHtml(getString(R.string.bind_mi_band_about)));
        this.f8754d.setOnClickListener(this);
        inflate.findViewById(R.id.start_bind).setOnClickListener(this);
        this.f8755e = (SlidingUpPanelLayout) inflate.findViewById(R.id.fragment_setting_sliding_layout);
        this.f8755e.setSlidingEnabled(false);
        m13560d();
        if (Config.m8876h().f4213w.booleanValue()) {
            this.f8754d.setVisibility(View.INVISIBLE);
        }
        return inflate;
    }
}
